<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>基本测试</title>
</head>
<body>
    <h1>DBC上传测试</h1>
    <input type="file" id="dbcFile" accept=".dbc">
    <button onclick="testUpload()">测试上传</button>
    <div id="result"></div>

    <script src="script.js"></script>
    <script>
        function testUpload() {
            const fileInput = document.getElementById('dbcFile');
            const file = fileInput.files[0];
            
            if (!file) {
                alert('请先选择一个文件');
                return;
            }

            console.log('开始测试文件:', file.name);
            
            // 检查DBCEditor是否存在
            if (typeof DBCEditor === 'undefined') {
                document.getElementById('result').innerHTML = '❌ DBCEditor类未定义';
                return;
            }

            try {
                const editor = new DBCEditor();
                console.log('DBCEditor创建成功');
                
                editor.loadDbcFile(file);
                document.getElementById('result').innerHTML = '✅ 文件加载调用成功，请查看控制台';
                
            } catch (error) {
                console.error('错误:', error);
                document.getElementById('result').innerHTML = '❌ 错误: ' + error.message;
            }
        }

        // 页面加载时检查环境
        window.onload = function() {
            console.log('检查环境...');
            
            const classes = ['DBCTokenizer', 'DBCParser', 'CANDatabase', 'CANFrame', 'CANSignal', 'DBCEditor'];
            classes.forEach(className => {
                if (typeof window[className] !== 'undefined') {
                    console.log(`✅ ${className} 可用`);
                } else {
                    console.error(`❌ ${className} 未定义`);
                }
            });
        };
    </script>
</body>
</html> 